#include "castelobrunomeira.h"

#include <GL/glu.h>
#include "gllib/Objects.h"

void CasteloBrunoMeira::draw() {
    glEnable(GL_COLOR_MATERIAL);
    glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);

    float mat_specular[] = {0.7, 0.7, 0.7, 1.0};
    float shininess = 20;

    glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
    glMaterialf(GL_FRONT, GL_SHININESS, shininess);

    glPushMatrix();
    construirTorres(0,0,0);
    construirPontaTorres(0,1.25,0);
    construirTorres(0,0,3);
    construirPontaTorres(0,1.25,3);
    construirTorres(3,0,3);
    construirPontaTorres(3,1.25,3);
    construirTorres(3,0,0);
    construirPontaTorres(3,1.25,0);
    construirParedeTras(1.5,-0.25,0);
    construirParedesLaterais(3,-0.25,1.5);
    construirParedesLaterais(0,-0.25,1.5);
    construirChao(1.5,-0.75,1.65);
    construirFrente(0.7,-0.25,3);
    glPopMatrix();

    glDisable(GL_COLOR_MATERIAL);
}

void  CasteloBrunoMeira::construirTorres(float x,float y, float z){
    glPushMatrix();
    glColor3f(0,0,1);
    glTranslatef(x,y,z);
    glScalef(1,1.5,1);
    gllibCylinder(0.5,1,100);
    glPopMatrix();
}

void CasteloBrunoMeira::construirPontaTorres(float x,float y, float z){
    glPushMatrix();
    glColor3f(0,0,1);
    glTranslatef(x,y,z);
    gllibCone(0.5,1,100);
    glPopMatrix();
}

void  CasteloBrunoMeira::construirParedeTras(float x,float y, float z){
    glPushMatrix();
    glColor3f(0,0,1);
    glTranslatef(x,y,z);
    glScalef(5,2,0.5);
    gllibCube(0.5);
    glPopMatrix();
}

void CasteloBrunoMeira::construirParedesLaterais(float x,float y, float z){
    glPushMatrix();
    glColor3f(0,0,1);
    glTranslatef(x,y,z);
    glScalef(0.5,2,5);
    //glRotatef(90,0,1,0);
    gllibCube(0.5);
    glPopMatrix();
}

void CasteloBrunoMeira::construirChao(float x,float y, float z){
    glPushMatrix();
    glColor3f(0,0,0);
    glTranslatef(x,y,z);
    glScalef(6.5,0.05,6.2);
    gllibCube(0.5);
    glPopMatrix();
}

void CasteloBrunoMeira::construirFrente(float x,float y, float z){
    glPushMatrix();
    glColor3f(0,0,1);
    glTranslatef(x,y,z);
    glScalef(1.75,2,0.5);
    gllibCube(0.5);
    glPopMatrix();

    glPushMatrix();
    glColor3f(0,0,1);
    glTranslatef(x+1.7,y,z);
    glScalef(2,2,0.5);
    gllibCube(0.5);
    glPopMatrix();

    glPushMatrix();
    glColor3f(0,0,1);
    glTranslatef(x+0.3,y+0.44,z);
    glScalef(5,0.3,0.5);
    gllibCube(0.5);
    glPopMatrix();

    glPushMatrix();
    glColor3f(0,1,1);
    glTranslatef(x+1.1,y,z);
    gllibCylinder(0.05,1,100);

    glTranslatef(x-0.9,0,0);
    gllibCylinder(0.05,1,100);

    glTranslatef(x-0.9,0,0);
    gllibCylinder(0.05,1,100);

    glTranslatef(x-0.9,0,0);
    gllibCylinder(0.05,1,100);
    glPopMatrix();
}
